$().ready(function(){
	$("[data-href]").on("click", function (e) {
        e.stopPropagation();location.href=$(this).data("href");
    });
})

/*trade history order*/
//订单详情  Token_Trading_History_Order.html
function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
var url=GetRequest();

$().ready(function(){
        var code=url.order;
//var code="a4a443b1-8f44-45ae-8f61-57922e1bd90d";
        if(!code){return true;}
      //查询消耗的平台币
        $.get("/app/public/ssw",function(r){
            console.log("消耗平台币",r);
            if(r.code==0){
                var txt=r.charge+"ssw"
                $("#platCoin").html(txt)
            }
        })
        $.ajax({
            url:"/app/order/showorder",
            type:"get",
            data:{code:code},
            success:function(r){
                console.log("order detail",r);
                if(r.code==0){
                    var data=r.orderEntity;
                    $("#formAdd").html(data.targetadd);//目标地址
                    $("#toAdd").html(data.refundadd);//存入地址
                    $("#transAdd").html(data.transferadd);//发送地址
                    $("#orderCode").html(data.code);//订单编号
                    $("#Oreder1").html(data.from);//目标地址币种
                    $("#Oreder3").html(data.from);
                    $("#Oreder2").html(data.to);//存放地址币种
                    $("#Oreder4").html(data.to);//存放地址币种
                    //二维码
                    //codeUrl
                    var qrcode = new QRCode("qrcode", {
                        text:data.transferadd,
                        width: 200,
                        height: 200,
                    });
                    if(data.orderstatus==1){//待转币
                       $("#orderStatus").html("待转币");
                    }else if(data.orderstatus==2){//已收到
                    	$("#orderStatus").html("已收到");
                    }else if(data.orderstatus==3){//成功
                    	$("#orderStatus").html("成功");
                    }else if(data.orderstatus==4){//失败
                    	$("#orderStatus").html("失败");
                    }
                    //查询矿工费
                    var OrderName1=data.from,OrderName2=data.to;	
                    $.ajax({
         				url:"/sys/exchangeRate/rate",
         			   	data:{turnout:OrderName1,receive:OrderName2},
         			   	success:function(r){
         			   		//console.log("汇率",r);
         			   		var data=r.doGet;
         			   		if(data.error){
         			   		$("#Transaction_exchange_rate").html(data.error);
         			   		return true;
         			   		}
         			   		$("#MaxLimit").html(data.maxLimit);
         			   		$("#MinLimit").html(data.minimum);
         			   		$("#mimuFree").html(data.minerFee);
         			   		var html=`1 ${OrderName1}= ${data.rate} ${OrderName2}`;
         			   		$("#orderRate").text(html);
         			   		
         			   	}
         			})
                }else{
                    alert(r.msg);
                }

            }
        })
    })
